*****************************************************************************************************************************************************
* PROJECT: 		Exposure to the COVID-19 Stock Market Crash and its Effect on Household Expectations
* DATE: 		Nov 2020
* CONTENT: 		TABLES
* AUTHORS: 		Tobin Hanspal, Johannes Wohlfart, Anni Weber
*****************************************************************************************************************************************************

		clear all
		set scheme lean2
		global pm = char(177)
		set more off
		gl date = c(current_date)
		graph set window fontface "cmr10"		
		
* set cd as /Replication_files_HanspalWeberWohlfart2020/


*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~						
** Table A5
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~	
	
use data/processed/data_1, clear 
keep if control_pure==1

* gen additional variables
gen h_constrained=(constrained>3)
gen h_age=(age>48)
tab hhnetinc_19 if hhnetinc19_NR==0
gen h_netinc=(hhnetinc_19>4)
gen h_netinc_alt=(hhnetinc_19>3)
replace h_netinc=. if hhnetinc19_NR==1

drop h_ofinwealth_lvl 
sum ofinwealth_lvl, d
gen h_ofinwealth_lvl=(ofinwealth_lvl>7500)

replace recov_owninc_duration=0 if recov_owninc_duration<0
sum recov_owninc_duration if recov_owninc_duration>0 , d
replace recov_owninc_duration=20 if never_owninc==1
gen h_recovinc=(recov_owninc_duration>0)

sum netwealth_Jan20, d
gen h_netwealth=(netwealth_Jan20<r(p50))
sum netwealth_Jan20 if h_age==0, d
gen age_low_nw_low=(h_age==0 & netwealth_Jan20<r(p50))
sum netwealth_Jan20 if h_age==0, d
gen age_low_nw_high=(h_age==0 & netwealth_Jan20>=r(p50))
sum netwealth_Jan20 if h_age==1, d
gen age_high_nw_low=(h_age==1 & netwealth_Jan20<r(p50))
sum netwealth_Jan20 if h_age==1, d
gen age_high_nw_high=(h_age==1 & netwealth_Jan20>=r(p50))

sum retirewealth_lvl, d
gen h_retirwealth=(retirewealth_lvl>r(p50))

tab svydate, gen(svydate_)

foreach var of varlist delhhnetinc_exp20_USD_tr02alt delhhnetinc_USD_tr02alt_qtr delretir_USD_tr02alt delofin_USD_tr02alt	{
	gen `var'_ts=`var'/1000
}
*

foreach var of varlist expec_debthigher expec_morehrs expec_retirlater{
	gen `var'_00=100* `var' 
}
* 

global controls ///
	ln_hhnetinc  ///
	ln_ofinwealth_lvl ln_retirewealth_lvl  ///
	ln_realestate_lvl realestJan20_NR		///
	ln_debt_lvl  debtJan20_NR ///
	stockinvestor riskshare_finwealth_Jan201 stockexperience ///
	age_25_34 age_35_44 age_45_54 age_55_64 age_65 male married separated_divorced widowed ///	
	highschool some_college_associate_degree atleast_bachelor  ///
	mainearner_alone z_constrained self_empl retired unempl empl_other ///
	republican other_party NR_party  ///
	z_decisionmaker ///
	midwest northeast south ///
	svydate_2 svydate_3 svydate_4 svydate_5 svydate_6 svydate_7 svydate_8 ///
	control_fincrisis control_dotcom control_black

loc experiments "del_spend20_perc_tr02 del_spend20_usd_tr02alt del_spend20_usd_tr02alt del_spend20_perc_tr02 del_spend20_perc_tr02 del_spend20_perc_tr02"

preserve

clear all
eststo clear
estimates drop _all

set obs 10
qui gen x = 1
qui gen y = 1

loc columns = 0

foreach choice in `experiments' {

    loc ++columns
    qui eststo col`columns': reg x y

}

restore

loc colnum = 1
loc colnames ""

*** Column 1:
			
reg del_spend20_perc_tr02 del_ofin_perc_tr02 del_retir_perc_tr02 del_hhnetinc_perc_tr02 $controls, robust

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar del_retir_perc_tr02, prec(3)
estadd loc thisstat2 = "`r(bstar)'": col1
estadd loc thisstat3 = "`r(sestar)'": col1

sigstar del_ofin_perc_tr02, prec(3)
estadd loc thisstat5 = "`r(bstar)'": col1
estadd loc thisstat6 = "`r(sestar)'": col1

sigstar del_hhnetinc_perc_tr02, prec(3)
estadd loc thisstat8 = "`r(bstar)'": col1
estadd loc thisstat9 = "`r(sestar)'": col1

estadd loc thisstat23 "Yes": col1
estadd loc thisstat24= `r2': col1
estadd loc thisstat25 = `N': col1


*** Column 2:
			
reg del_spend20_usd_tr02alt delretir_USD_tr02alt delofin_USD_tr02alt delhhnetinc_USD_tr02alt_qtr $controls, robust

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar delretir_USD_tr02alt, prec(3)
estadd loc thisstat11 = "`r(bstar)'": col2
estadd loc thisstat12 = "`r(sestar)'": col2

sigstar delofin_USD_tr02alt, prec(3)
estadd loc thisstat14 = "`r(bstar)'": col2
estadd loc thisstat15 = "`r(sestar)'": col2

sigstar delhhnetinc_USD_tr02alt_qtr, prec(3)
estadd loc thisstat17 = "`r(bstar)'": col2
estadd loc thisstat18 = "`r(sestar)'": col2

estadd loc thisstat23 "Yes": col2
estadd loc thisstat24= `r2': col2
estadd loc thisstat25 = `N': col2



*** Column 3:
			
ivreg2 del_spend20_usd_tr02alt (delhhnetinc_exp20_USD_tr02alt=delhhnetinc_USD_tr02alt_qtr) delretir_USD_tr02alt delofin_USD_tr02alt	$controls, robust

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar delretir_USD_tr02alt, prec(3)
estadd loc thisstat11 = "`r(bstar)'": col3
estadd loc thisstat12 = "`r(sestar)'": col3

sigstar delofin_USD_tr02alt, prec(3)
estadd loc thisstat14 = "`r(bstar)'": col3
estadd loc thisstat15 = "`r(sestar)'": col3

sigstar delhhnetinc_exp20_USD_tr02alt, prec(3)
estadd loc thisstat20 = "`r(bstar)'": col3
estadd loc thisstat21 = "`r(sestar)'": col3

estadd loc thisstat23 "Yes": col3
estadd loc thisstat24= `r2': col3
estadd loc thisstat25 = `N': col3


*** Column 4:
			
reg expec_debthigher_00 del_ofin_perc_tr02 del_retir_perc_tr02 del_hhnetinc_perc_tr02 $controls, robust

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar del_retir_perc_tr02, prec(3)
estadd loc thisstat2 = "`r(bstar)'": col4
estadd loc thisstat3 = "`r(sestar)'": col4

sigstar del_ofin_perc_tr02, prec(3)
estadd loc thisstat5 = "`r(bstar)'": col4
estadd loc thisstat6 = "`r(sestar)'": col4

sigstar del_hhnetinc_perc_tr02, prec(3)
estadd loc thisstat8 = "`r(bstar)'": col4
estadd loc thisstat9 = "`r(sestar)'": col4

estadd loc thisstat23 "Yes": col4
estadd loc thisstat24= `r2': col4
estadd loc thisstat25 = `N': col4


*** Column 5:
			
reg expec_morehrs_00 del_ofin_perc_tr02 del_retir_perc_tr02 del_hhnetinc_perc_tr02 $controls, robust

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar del_retir_perc_tr02, prec(3)
estadd loc thisstat2 = "`r(bstar)'": col5
estadd loc thisstat3 = "`r(sestar)'": col5

sigstar del_ofin_perc_tr02, prec(3)
estadd loc thisstat5 = "`r(bstar)'": col5
estadd loc thisstat6 = "`r(sestar)'": col5

sigstar del_hhnetinc_perc_tr02, prec(3)
estadd loc thisstat8 = "`r(bstar)'": col5
estadd loc thisstat9 = "`r(sestar)'": col5

estadd loc thisstat23 "Yes": col5
estadd loc thisstat24= `r2': col5
estadd loc thisstat25 = `N': col5


*** Column 6:
			
reg expec_retirlater_00 del_ofin_perc_tr02 del_retir_perc_tr02 del_hhnetinc_perc_tr02 $controls, robust

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar del_retir_perc_tr02, prec(3)
estadd loc thisstat2 = "`r(bstar)'": col6
estadd loc thisstat3 = "`r(sestar)'": col6

sigstar del_ofin_perc_tr02, prec(3)
estadd loc thisstat5 = "`r(bstar)'": col6
estadd loc thisstat6 = "`r(sestar)'": col6

sigstar del_hhnetinc_perc_tr02, prec(3)
estadd loc thisstat8 = "`r(bstar)'": col6
estadd loc thisstat9 = "`r(sestar)'": col6

estadd loc thisstat23 "Yes": col6
estadd loc thisstat24= `r2': col6
estadd loc thisstat25 = `N': col6



loc rowlabels " " " "$\Delta$ Retirement fin. wealth (\%)" " " " " "$\Delta$ Other fin. wealth (\%)" " " " "  "$\Delta$ Net income (quarterly, \%)" " " " " "$\Delta$ Retirement fin. wealth (\$)" " " " " "$\Delta$ Other fin. wealth (\$)" " " " "  "$\Delta$ Net income (quarterly, \$)"  " " " "  "$\Delta$ Net income (annual, \$)" " " " " "Individual controls" "Adj. R-squared" "Observations" " 

forval i = 1/25 {
    loc rowstats "`rowstats' thisstat`i'"
}


esttab * using "Tables\TableA5.tex", replace cells(none) booktabs nonotes nomtitles compress alignment(c) nogap noobs nobaselevels label stats(`rowstats', labels(`rowlabels')) ///
     mgroups( "\shortstack{Exp.\\spend.\\growth (\%)}" "\shortstack{Exp.\\spend.\\growth (\$)}" "\shortstack{Exp.\\spend.\\growth (\$)}" "\shortstack{Incr.\\ exp.\\ debt}" "\shortstack{Incr. exp. \\ desired \\ hours}" "\shortstack{Incr. exp.\\ retirement \\ age}", pattern(1 1 1 1 1 1  ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))













